package middleware

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
	"zlxBook/Response"
)

func RecoverMiddleWare() gin.HandlerFunc {
	return func(context *gin.Context) {
		defer func() {
			if err := recover(); err != nil {
				fmt.Println(err)
				context.JSON(http.StatusUnsupportedMediaType, Response.MessageMaker("pannic"))
			}
		}()
		context.Next()
	}

}
